package com.hps.webservice.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hps.webservice.entity.User;
import org.springframework.stereotype.Component;

import javax.jws.WebService;

/**
 * @author hepengshuai
 * @date 2018/12/7 20:47
 */
@WebService(name = "TestService",
        targetNamespace = "http://service.webservice.hps.com",
endpointInterface = "com.hps.webservice.service.TestService")
@Component
public class TestServiceImpl implements TestService {
    @Override
    public String sendMessage(String username) {
        User user = new User();
        user.setId(1);
        user.setUsername(username);

        ObjectMapper mapper = new ObjectMapper();
        String str = null;
        try {
            str = mapper.writeValueAsString(user);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        System.out.println(username);
        return str;
    }

    @Override
    public String sayHello(String username) {
        return "hello";
    }
}
